package com.ds.introduce;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.junit.Test;

public class Test5 {

	@Test
	public void delete() {
		
		List<String> strList = new ArrayList<String>();
		
		strList.add("aaa");
		strList.add("bbb");
		strList.add("ccc");
		strList.add("ddd");
		
		for(String str : strList) {
			strList.remove(str);
		}
	}
	
	@Test
	public void deleteByIterater() {
		
		List<String> strList = new ArrayList<String>();
		
		strList.add("aaa");
		strList.add("bbb");
		strList.add("ccc");
		strList.add("ddd");
		
		System.out.println(strList);
		
		Iterator<String> iter = strList.iterator();
		
		while(iter.hasNext()) {
			iter.next();
			iter.remove();
		}
		
		System.out.println(strList);
		
	}
}
